package com.woniu.service.bean;

import com.woniu.util.ApplicationContextHolder;
import lombok.Data;

import java.math.BigDecimal;

@Data
public class AddSellRecord {
    private Integer id;
    private Integer userId;
    private String dealTime;
    private BigDecimal dealPrice;
    private BigDecimal userIncome;
    private BigDecimal dealCharge;
    private String productType;
    private AddSellRecordHandler handler;

    public AddSellRecord(){
        this.handler = ApplicationContextHolder.getApplicationContext().getBean(AddSellRecordHandler.class);
    }

    public AddSellRecord(Integer id, Integer userId, String dealTime, BigDecimal dealPrice, BigDecimal userIncome, BigDecimal dealCharge, String productType) {
        this();
        this.id = id;
        this.userId = userId;
        this.dealTime = dealTime;
        this.dealPrice = dealPrice;
        this.userIncome = userIncome;
        this.dealCharge = dealCharge;
        this.productType = productType;
    }

    public void execute() {
        handler.action(this);
    }
}
